
t2 = read_mrt('ancillary/Rathborne_2009_Table2.mrt')
t3 = read_mrt('ancillary/Rathborne_2009_Table3.mrt')

help,t3,/str

myps,'./grs_paper/grs_clumps.eps',xsize=10,ysize=10

multiplot_xm,[2,2],mpcharsize=1.0,xgap=0.035,ygap=0.035,/doxaxis

;; cgPlot,t3.glon,t3.vlsr,psym=16,symsize=0.4,xr=[70,10],charsize=1.0,$
;;        yr=[-10,140],xtit='GLON  [deg]',ytit='V!dLSR!n  [km s!u-1!n]'

;; cgPlot,t3.dlon,t3.dlat,psym=16,symsize=0.4,xtit='DLON',ytit='DLAT',$
;;        charsize=1.0
;; one2one,color='cyan',linestyle=2,thick=4
exten = (t3.dlon + t3.dlat)/2.
plothist,exten*60.,bin=0.25,charsize=1.0,ytit='N per bin',$
         xtit='Extent  [arcmin]'

al_legend,/top,/right,box=0,['GRS Clumps']

print,n_elements(t3)


conf = omni_load_conf()
s = omni_read_cat(conf.cat,ncat)

ct = 0

mind = fltarr(ncat)
aex  = fltarr(ncat)

FOR ii=0,ncat-1 DO BEGIN
   
   l = s[ii].glon
   b = s[ii].glat
   
   gcirc,2,l,b,t3.glon,t3.glat,dis
   
   mind[ii] = min(dis,jj)
   
   IF mind[ii] GT 3600.*.25 THEN CONTINUE
   
   print,l,min(dis)
   ct++
   aex[ii] = exten[jj]
   
   
   
ENDFOR

print,ct

multiplot,/doyaxis,/doxaxis

;; Plot of the BGPS - GRS Separation

plothist,mind/60.,xr=[0,15],bin=0.25,charsize=1.0,xtickinterval=5,$
         xtit='GRS - BGPS separation  [arcmin]',ytit='N per bin'

vline,33./60.,color='green'


multiplot,/doyaxis,/doxaxis

;; Plot of the Ratio of EXTENT / SEPARATION

ni = where(mind/60. LE 15., nni)
print,nni

ex_sep = aex[ni] / mind[ni] * 3600.

help,aex,mind,ex_sep
ei = where(finite(alog10(ex_sep)),nei)
print,nei
ex_sep = ex_sep[ei]

plothist,alog10(ex_sep),bin=0.1,charsize=1.0,xst=5
cgAxis,xaxis=0,/xlog,xr=10.^!x.crange,xtickformat='exponent10',charsize=1.0,$
       /xst,/save,xtit='Extent / Separation'
cgAxis,xaxis=1,xtickformat='blank_axis',/xst

xr = !x.crange

vline,1,color='cyan'
cgArrow,1,0.875*!y.crange[1],5,0.875*!y.crange[1],/data,thick=3,$
        /solid,color='cyan'
cgText,8,0.9*!y.crange[1],'Associated',align=0.5,color='cyan',charsize=1.0


multiplot,/doxaxis,/doyaxis

cgPlot,alog10(ex_sep),mind[ni]/60.,psym=16,symsize=0.4,xst=5,xr=xr,$
       ytit='GRS - BGPS separation  [arcmin]',charsize=1.0
cgAxis,xaxis=0,/xlog,xr=10.^!x.crange,xtickformat='exponent10',charsize=1.0,$
       /xst,/save,xtit='Extent / Separation'
cgAxis,xaxis=1,xtickformat='blank_axis',/xst

vline,1,color='cyan'
cgArrow,1,0.875*!y.crange[1],5,0.875*!y.crange[1],/data,thick=3,$
        /solid,color='cyan'
cgText,8,0.9*!y.crange[1],'Associated',align=0.5,color='cyan',charsize=1.0

vline,33./60.,color='green',/h,/xlog


myps,/done,/mp









END
